/*
 * EventQueue.h
 *
 *  Created on: 2014年5月28日
 *      Author: ellzu
 */

#ifndef EVENTQUEUE_H_
#define EVENTQUEUE_H_

#include "Event.h"
#include <vector>

namespace EventRunLoop {

class EventQueue
{
public:
	EventQueue(bool obstruct = true);
	virtual ~EventQueue();

public:
	void poseEvent( Event *event);
	Event* takeEvent(); //if next is null ,wait has event return event
	void endEvent(Event*);
	Event* nextEvent(); //if next is null return null
protected:
	bool _obstruct;
	pthread_mutex_t _mutex;
	pthread_cond_t _cond;
	std::vector< Event*> _events;
};

} /* namespace EventRunLoop */

#endif /* EVENTQUEUE_H_ */
